<template>
	<div class="back_contain_n">
		<!-- 头部搜索 -->
		<div class="Search_Top_Part">
			<div class="search_list">
				<div>
					<div class="input_flex">
						<el-select clearable v-model="queryForm.itemId" placeholder="品类">
							<el-option v-for="(item,index) in itemList" :key="index" :label="item"
									   :value="item"/>
						</el-select>
					</div>
					<div class="input_flex">
						<el-select clearable v-model="queryForm.gradeValue" placeholder="规格">
							<el-option v-for="(item,index) in gradeList" :key="index" :label="item"
									   :value="item"/>
						</el-select>
					</div>
				</div>
			</div>
			<div class="search_bt">
				<span class="zll-search" @click="getList">搜索</span>
				<span class="zll-search-reset" @click="searchReset()">重置</span>
			</div>
		</div>
		<div class="input_flex">
			<span class="search_left">出库总量：</span><span>280,000,000</span>
		</div>
		<div class="input_flex">
			<span class="search_left">同期平均库存：</span><span>284,264,061</span>
		</div>
		<!-- table -->
		<sys-table
			:tableData="tableData"
			:tableLoading="tableLoading"
			:tableHeader="tableHeader"
			:scopeWidth="120"
			:is-operate="false"
			ref="systable"

		>

		</sys-table>

	</div>
</template>

<script>
import {formatDate} from "@/plugins/formatDate";
import {getStore} from "@/plugins/localStore";

export default {
	data() {
		return {
			tableLoading: true, //table刷新
			type: '',
			editData: {},

			queryForm: {
				gradeValue: '',
				itemId: '',
			},
			gradeList:[],
			itemList:['单支连排','多支','伸缩','U型'],
			backCount: 0,
			tableData: [],
			tableHeader: [],
			addDialog: false,
			time: [],

			userList: [],
		}
	},
	methods: {


		getList() {
			debugger
			let self = this;
			self.tableLoading = true;
			self.$refs.systable.resetPage();
			// let pageInfo = self.$refs.systable.getPageInfo(startIndex);
			// if (pageInfo.pageNum == 0||startIndex == 0) {
			// 	self.$refs.systable.resetPage();
			// }
			// self.queryForm.startIndex = pageInfo.pageNum;
			// self.queryForm.totalPage = pageInfo.pageSize;
			debugger
			let param = Object.assign({}, self.queryForm);
			self.$http({
				url: "/jinl/order/getInventory",
				method: "post",
				data: JSON.stringify(param),
				dataType: 'json',
				contentType: "application/json",
			}).then(resp => {
				if (resp.success) {
					let userId = getStore().id;
					self.tableLoading = false;
					for(let data of resp.result){
						if(data.createUserId != userId){
							// data.price = '*****';
							// data.totalPrice = '******';
						}
					}
					self.tableData = resp.result;
					self.tableHeader = [
						{"columnValue": "orderType", "columnName": "类型"},
						{"columnValue": "customer", "columnName": "客户",width: 200,overFlow:true},
						{"columnValue": "itemTypeId", "columnName": "品类"},
						{"columnValue": "productName", "columnName": "产品名称",width: 180,overFlow:true},
						{"columnValue": "gradeValue", "columnName": "规格", width: 180,overFlow:true},
						{"columnValue": "storageCount", "columnName": "当前库存" },
					];
					if (resp.result.length > 0) {
						self.backCount = resp.result[0].count;
					} else {
						self.backCount = 0;
					}
				}
			});

		},
		getOrderGrades() {
			let self = this;
			self.gradeList = [];
			self.$http({
				url: "/jinl/order/getOrderGrades",
				method: "post",
			}).then(resp => {
				if (resp.success) {
					self.gradeList = resp.result;
				}
			});
		},


		searchReset() { //重置搜索
			this.queryForm = {
				itemId: '',
				gradeValue: '',
			};
			this.getList();
		},
	},
	mounted() {
		let self = this;
		self.getList()
		self.getOrderGrades();
	},

}
</script>

<style lang="scss" scoped>
@import "@/style/SearchTop.scss";
</style>